import("//llvm/lib/Target/targets.gni")

static_library("Rewrite") {
  output_name = "LLVMBOLTRewrite"
  configs += [ "//llvm/utils/gn/build:bolt_code" ]
  deps = [
    "//bolt/lib/Core",
    "//bolt/lib/Passes",
    "//bolt/lib/Profile",
    "//bolt/lib/RuntimeLibs",
    "//bolt/lib/Utils",
    "//llvm/lib/DWP",
    "//llvm/lib/DebugInfo/DWARF",
    "//llvm/lib/ExecutionEngine",
    "//llvm/lib/MC",
    "//llvm/lib/Object",
    "//llvm/lib/Support",
    "//llvm/lib/TargetParser",
    "//llvm/utils/gn/build/libs/pthread",
  ]
  sources = [
    "BinaryPassManager.cpp",
    "BoltDiff.cpp",
    "DWARFRewriter.cpp",
    "ExecutableFileMemoryManager.cpp",
    "MachORewriteInstance.cpp",
    "RewriteInstance.cpp",
  ]

  defines = []
  if (llvm_build_AArch64) {
    defines += [ "AARCH64_AVAILABLE" ]
    deps += [ "//bolt/lib/Target/AArch64" ]
  }
  if (llvm_build_X86) {
    defines += [ "X86_AVAILABLE" ]
    deps += [ "//bolt/lib/Target/X86" ]
  }
}
